<%@ page language="java" import="java.util.*,java.net.URLEncoder" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<link rel="shortcut icon" href="<%=basePath%>favicon.ico" type="image/x-icon" />
<link type="text/css" href="<%=basePath%>style/bace.css" rel="stylesheet"/>
<link type="text/css" href="<%=basePath%>style/block.css" rel="stylesheet"/>
<link rel="stylesheet" type="text/css" href="<%=basePath%>style/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="<%=basePath%>style/themes/icon.css">
<link rel="stylesheet" type="text/css" href="<%=basePath%>style/demo.css">
<script type="text/javascript" src="<%=basePath%>javascript/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="<%=basePath%>javascript/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=basePath%>javascript/pub.js"></script>
<script type="text/javascript" src="<%=basePath%>javascript/easyui_pub.js"></script>
<script type="text/javascript" src="<%=basePath%>javascript/locale/easyui-lang-zh_CN.js"></script>
<title>医疗收费查询系统</title>
</head>

<body onload="markCode()" >
<div class="content S_login_bg">
	<div class="col_main">
		<dl>
			<dt>用 户：</dt><dd><div id="codeMsg" STYLE="z-index: 999; position: absolute; padding-left: 5px; padding-top: 11px; color: rgb(184, 184, 184); display: block;" onclick="codeMsgHide()">请输入用户编码</div><input id="code" name="F_CODE" required="true" missingMessage="必填" class="easyui-validatebox" onfocus="hideCode()" onblur="codeMsgShow()"/></dd>
			<dt>密 码：</dt><dd><div id="pwdMsg" STYLE="z-index: 999; position: absolute; padding-left: 5px; padding-top: 11px; color: rgb(184, 184, 184); display: block;" onclick="pwdMsgHide()">请输入用户密码</div><input id="pwd"  name="F_PASSWORD" required="true" missingMessage="必填" class="easyui-validatebox" type="password" onfocus="hidePwd()" onkeydown="entr()" onblur="pwdMsgShow()"/></dd>
			<!--<dt>验证码：</dt><dd><input id="validCode" name="validCode" class="code" required="true" missingMessage="必填" class="easyui-validatebox" onkeydown="entr()" />&nbsp;<img id="codeImg" align="absmiddle" onclick="markCode()"/>&nbsp;<button name="refresh"  type="button" onclick="markCode()" style="width: 50px;height: 30px">刷新</button></dd>-->
		</dl>
		<div class="Bottom_all">
			<span><input id="Login" class="Signin" type="button" onclick="login()" onkeydown="entr()"/></span><span><input class="Cancel" type="button" onclick="reSet()"/></span>
		</div>
	</div>
</div>
<div style="display: none;">
<form id="homeForm" action="action/master/usermanage/home.do" method="post">
<input id="Taken" name="Token" value="" />
</form>
</div>

<div class="content footer">
技术支持：福州博思软件技术有限公司 备案号：56565656<br/>
             CopyRight©2012

</div>
</body>

</html>
<script type="text/javascript" >
    var Token='';
    
    function hideCode(){
        $('#codeMsg').hide();
    }
    
    function hidePwd(){
        $('#pwdMsg').hide();
    }
    
    function codeMsgHide(){
        $('#codeMsg').hide();
        $('#code').focus();
    }
    
    function pwdMsgHide(){
        $('#pwdMsg').hide();
        $('#pwd').focus();
    }
    
    function codeMsgShow(){
        if($.trim($('#code').val())=='')
            $('#codeMsg').show();
    }
    
    function pwdMsgShow(){
        if($.trim($('#pwd').val())=='')
        $('#pwdMsg').show();
    }
    
    function markCode(){

	    		$.ajax({
	    			url:'action/master/usermanage/getToken.json?rnd='+Math.random(),
	    			dataType:"json",
	    			success:function(data){
	    				if(data.Token){
	    					Token=data.Token;
	    					var src='<%=basePath%>action/master/usermanage/getValidCode.do?Token='+Token+'&rnd='+Math.random();
	    					$("#codeImg").attr("src",src);
	    				}
	    			},
	    			error:function(){
	    				$.messager.alert("提示","未获得服务器响应...");
	    			}
	    		});
    }
    function login(){
	    var code=$('#code').attr('value');
	    var pwd=$('#pwd').attr('value');
	    var msg="";
	    if($.trim(code)==''){
	        $.messager.alert('提示','用户不能为空 ');
	    }    
	    else if($.trim(pwd)==''){
	        $.messager.alert('提示','密码不能为空');
	    }
	    else{  
	    var validCode=$('#validCode').attr('value');
	    $.post('action/master/usermanage/login.do?', { Action: "post", F_CODE:code,F_PASSWORD:pwd,validCode:validCode,Token:Token,rnd:Math.random()},
		function (data, textStatus){
		    msg=data.msg;
		    if(data.Token){
	    	  Token=data.Token;
	    	  } 
			if(data.msg)
	          $.messager.alert('提示',data.msg);
	       else{
	          $('#Taken').val(Token);
	          $('#homeForm').submit();  
	          }

		}, "json");
		    
		return false; 
		}
    }
    
    function reSet(){
       $('#code').attr('value','');
       $('#pwd').attr('value','');
       $('#validCode').attr('value','');
    }
    
    function entr(){
		if (event.keyCode == 13)    {
        	login();
    	 }
    }
    
     $(function () {
        $('input:text:first').focus();
        var $inp = $('input');
        $inp.bind('keydown', function (e) {
            var key = e.which;
            if (key == 13) {
                e.preventDefault();
                var nxtIdx = $inp.index(this) + 1;
                if($(":input:eq(" + nxtIdx + ")").attr("name")!="refresh")
                    var id=$(":input:eq(" + nxtIdx + ")").attr('id');
                    $("#"+id+"Msg").hide();
                    $(":input:eq(" + nxtIdx + ")").focus();
            }
        });
    });
    
    $('#Login').focus();
</script>